package com.hallo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.atomic.AtomicLong;


/**
 * Created by Chan on 2017/5/23.
 */
@RestController
public class GeentionController {
    private static final String template = "Hello, %s!";
    private final AtomicLong counter = new AtomicLong();

    @RequestMapping(value = "/greeting",method = RequestMethod.GET)
    public Geention greeting(@RequestParam(value="name", defaultValue="World") String name) {
        return new Geention(counter.incrementAndGet(),
                String.format(template, name));
    }
}
